package com.example.myweb.Domain.Enum;

public enum LikeTargetType {
    ARTICLE,
    DYNAMIC,
    COMMENT;

    /**
     * 一个辅助方法，用于从字符串安全地转换为枚举。
     * 它可以处理大小写和无效值。
     * @param typeString 传入的字符串，如 "article"
     * @return 对应的枚举值
     * @throws IllegalArgumentException 如果字符串无效
     */
    public static LikeTargetType fromString(String typeString) {
        if (typeString == null) {
            throw new IllegalArgumentException("Target type string cannot be null");
        }
        try {
            // toUpperCase() 使得 "article", "Article", "ARTICLE" 都能正确转换
            return LikeTargetType.valueOf(typeString.toUpperCase());
        } catch (IllegalArgumentException e) {
            throw new IllegalArgumentException("Unknown target type: " + typeString, e);
        }
    }
}